#include <msp430.h>
#include <stdint.h>

#include "common.h"

void myfunc(void);

void stk_init(uint8_t *stkloc, int size)
{
	int i;
	uint8_t val = (uint8_t) stkloc; /* Truncate address into val */
	for (i=0; i<size; i++) {
		stkloc[i] = val++;
	}
}


uint8_t stk_crc(uint8_t *stkloc, int size)
{
	int i;
	uint8_t val = 0;
	for (i=0; i<size; i++) {
		val += stkloc[i];
	}	
	return val;
}


static uint8_t func_static(uint8_t val)
{
	STK_INIT(7);
	val = val + 7 + P1IN;
	return val;
}


int main(void) 
{
	int x;
	STK_INIT(10);

	P2OUT = func_static(3);;
	f4(P1IN, f11);
	f9(P1IN, f11);

#if TST_RECURSION
	fn_recursive1(P1IN);
	fn_recursive2(P1IN);

#endif

	for(;;) {
	}

}


__attribute__((interrupt(PORT1_VECTOR)))
void port1_isr(void)
{
	STK_INIT(4);
	f11(P1IN);
	
}
